// pages/myTeam/myTeam.js
import {
  request
} from '../../request/index.js'
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    user:{},
    http:'',
    code:0,//直推
    jian:0,//间推
    revenue:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let userInfo = typeof wx.getStorageSync('userInfo')==='string'? JSON.parse(wx.getStorageSync('userInfo')):wx.getStorageSync('userInfo');
    let user = typeof wx.getStorageSync('user')==='string'? JSON.parse(wx.getStorageSync('user')):wx.getStorageSync('user');
    this.setData({
      userInfo,
      user,
      http: app.globalData.http
    });
    request({
      url:'user/getDirect',
      data: {
        user_id:this.data.user.user_id
      },
    }).then((result) => {
      console.log(result);
      this.setData({
        code:result.data.code,//直推
        jian:result.data.data//间推
      })
    });
  },
  onShow:function(){
    request({
      url:'SplitRecord/getUserFenChengCount',
      data: {
        split_user_id:this.data.user.user_id
      },
    }).then((result) => {
      this.setData({
        revenue:result.data.data
      })
    })
  }

})